<?php
/**
 * Created by PhpStorm.
 * User: 哇咔咔
 * Date: 17-9-4
 * Time: 上午10:59
 */

defined('BASEPATH') OR exit('No direct script access allowed');

class Project extends MY_Controller {
    function index(){
        $data['company'] = parent::company();//公司基本信息
        $data['url'] =parent::pic_url($data['company'] ['id']);
        $arr1 = parent::arr();
        //获取项目类型
        $data['project_type'] = $this->db->from('product_type')->where($arr1)->get()->result_array();
        //获取项目列表
        $data['project'] = $this->db->from('product_info')->where($arr1)->get()->result_array();

        $this->load->view('project/project',$data);
    }

    //项目类型
    function type(){
        $id = $this->uri->segment(4);
        $data['company'] = parent::company();//公司基本信息
        $data['url'] =parent::pic_url($data['company'] ['id']);
        $arr1 = parent::arr();
        //获取项目类型
        $data['project_type'] = $this->db->from('product_type')->where($arr1)->get()->result_array();
       if($id!='both'){
            $arr = array('type_id'=>$id,'company_id'=>$data['company'] ['id'],'del_flag' =>  '0',);}
       else{
           $arr = parent::arr();

       }
        //获取项目列表
        $data['project'] = $this->db->from('product_info')->where($arr)->get()->result_array();
        $this->load->view('project/project_type',$data);
    }


    //项目的详细信息
    function info(){
        $id = $this->uri->segment(4);
        $data['company'] = parent::company();//公司基本信息
        $data['url'] =parent::pic_url($data['company'] ['id']);
        $arr1 = parent::arr();
        //获取项目的总个数
        $num = $this->db->count_all_results('product_info');
        //随机获取显示项目的个数
        $data['project'] = $this->db->from('product_info')->where($arr1)->limit(rand(3,4),rand(0,$num-1))->get()->result_array();
        $arr = parent::arr_id($id);
        //项目的详细信息
        $data['info'] = $this->db->from('product_info')->where($arr)->get()->row_array();
        $this->load->view('project/project_show',$data);
    }
}